package compiler.exceptions;

import compiler.HowlToken;

/**
 * Superclass for all exceptions thrown by the Howl compiler.
 * 
 * @author Sarah Mount <s.mount@wlv.ac.uk>
 * @version 16 Dec 2009
 * 
 * @see HowlToken
 */

@SuppressWarnings("serial")
public class HowlException extends Exception {

	private static String format_carat(int char_no) {
		String str = "";
		for (int i = 0; i < char_no; i++) {
			str += " ";
		}
		return str + "^";
	}

	@SuppressWarnings("unused")
	private final String howl_stmt;
	@SuppressWarnings("unused")
	private final int char_no;

	public HowlException(String message, String howl_stmt, int char_no) {
		super(message + "\n" + howl_stmt + HowlException.format_carat(char_no));
		this.howl_stmt = howl_stmt;
		this.char_no = char_no;
	}
}
